package com.ruoyi.web.controller.littleRedBook;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.littleRedBook.domain.pojo.Store;
import com.ruoyi.littleRedBook.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * <p>
 * 门店表 前端控制器
 * </p>
 *
 * @author
 * @since 2025-09-10
 */
@RestController
@RequestMapping("/api/store")
public class StoreController {

    @Autowired
    private StoreService storeService;

    /**
     * 新增门店
     */
    @PostMapping
    public AjaxResult add(@RequestBody Store store) {
        return AjaxResult.success(storeService.save(store));
    }

    /**
     * 修改门店
     */
    @PutMapping
    public AjaxResult edit(@RequestBody Store store) {
        return AjaxResult.success(storeService.updateById(store));
    }

    /**
     * 删除门店
     */
    @DeleteMapping("/{storeIds}")
    public AjaxResult remove(@PathVariable Long[] storeIds) {
        return AjaxResult.success(storeService.removeByIds(Arrays.asList(storeIds)));
    }

    /**
     * 查询门店详情
     */
    @GetMapping("/{storeId}")
    public AjaxResult getInfo(@PathVariable Long storeId) {
        return AjaxResult.success(storeService.getById(storeId));
    }

    /**
     * 查询门店列表
     */
    @GetMapping
    public AjaxResult list() {
        return AjaxResult.success(storeService.list());
    }
}
